<script setup>
import dayjs from 'dayjs';

definePageMeta({
	layout: "flat",
})
const urlHome = useUrlRasp();

// const patientUid = ref('');
// const patientFam = ref('');
// const patientIm = ref('');
// const patientOt = ref('');
// const patientDr = ref(new Date());
// const patientAdress = ref('');
const patFam = ref('');
const inputFam = ref('');

watchDebounced(
	inputFam,
	() => { patFam.value = inputFam.value },
	{ debounce: 1000, maxWait: 2000 },
)

const { data: allPatients, refresh: allPatientsRefresh } = await useFetch(`${urlHome.value}lab/patients_by_fam`, {
	immediate: false,
	query: {
		fam: patFam,
	},
	watch: [patFam],
})

// async function savePatient() {
// 	let formData = new FormData();
// 	formData.append('patient_uid', patientUid.value)
// 	formData.append('patient_fam', patientFam.value)
// 	formData.append('patient_im', patientIm.value)
// 	formData.append('patient_ot', patientOt.value)
// 	formData.append('patient_dr', patientDr.value)
// 	formData.append('patient_adress', patientAdress.value)

// 	const response = await $fetch(`${urlHome.value}lab/add_comment`, {
// 		method: 'POST',
// 		body: formData
// 	})
// 	if (response.ok) {
// 		console.log(response.status);
// 	} else {
// 		alert("Ошибка сохранения комментария " + response.message);
// 	}
// }

</script>

<template>
	<div>
		<h1></h1>
		<br>
		<NaryadListWork>
			<NuxtLink to="/menu">
				<UButton>Меню</UButton>
			</NuxtLink>
		</NaryadListWork>
		{{ allPatients }}
		<br>
	</div>
</template>